Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
How to import sodium-plus directly into a .js file? "module does not provide an export named 'default'"

I would like to import sodium-plus to use within a .js file in a Chrome extension. The library's documentation only shows how to include the extension from an html file with a <script> tag. When I do that I get an error:

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'".

I tried to import directly through a .js file:

import SodiumPlus from "./sodium-plus.min.js";
(async function() {
    if (!window.sodium) window.sodium = await SodiumPlus.auto();

    // You can now use the sodium object here.

    // Just some example code to ensure it's running:
    let random = await sodium.randombytes_buf(32);
    let hash = await sodium.crypto_generichash('hello world');
    console.log({
        'random': random.toString('hex'),
        'hash': hash.toString('hex')
    });
})();

But received an error:

Uncaught SyntaxError: The requested module './sodium-plus.min.js' does not provide an export named 'default'

Is there any way to fix that? Alternatively, is there a similar library that would be easier to import into a .js file of a Chrome extension?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda